package org.example.domain.user_raffle.service.engine.handler;

import org.example.domain.user_raffle.model.entity.ActivityStrategyPrizeEntity;
import org.example.domain.user_raffle.repository.IUserRaffleRepo;
import org.example.domain.user_raffle.service.engine.RaffleHandlerNode;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author lxc18
 * @date 2025/3/29 20:27
 * @description DefaultHandler
 */
@Component
public class DefaultHandler extends RaffleHandlerNode {
    @Resource
    private IUserRaffleRepo userRaffleRepo;
    @Override
    public List<Long> doHandler(Long userId, Long activityId,int usedQuota, Map<String, ActivityStrategyPrizeEntity> strategyPrizeEntities) {
        //查询默认策略
        List<Long> prizeIds = new ArrayList<>();
        ActivityStrategyPrizeEntity defaultStrategy = strategyPrizeEntities.get("default");
        if (defaultStrategy != null){
            //默认策略
            String[] defaultPrizes = defaultStrategy.getPrizeIds().split(",");
            for (String prizeId : defaultPrizes) {
                prizeIds.add(Long.parseLong(prizeId));
            }
        }
        return prizeIds;
    }
}
